<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<%@ include file="/common/import.jsp" %>
<script>
  var thsTitle = "报价服务器管理";
  var currentPage = 1;
  var objName="server";
  var currentObjId = "";
</script>
<title>报价服务器-${sysName }</title>
</head>
<body class="home-template2">
<!-- 正文开始 -->
<div class="searchForm">
	<form id="orgList_form">
		<input type="hidden" name="page"  value="1">
		<input type="hidden" name="rows"  value="5">
		服务器名称：<input type="text" name="serverCname"  value="" /> 
		<a class="easyui-linkbutton"  iconCls="icon-search" onclick="serverListSearch();">查询</a>
		<a class="easyui-linkbutton"  iconCls="icon-add" onclick="addOPen();">增加服务器</a>
	</form>
</div>
<table id="serverList_table" class="info" cellspacing="1" cellpadding="0">
	<tr class='active' id="title2" >
		<th width='30%'>服务器名称</th>
		<th width='10%'>IP地址</th>
		<th width='10%'>端口</th>
		<th width='8%'>状态</th>
		<th width='16%'>加入时间</th>		
		<th width='15%' class='th_center'>操作</th>
	</tr>
</table>
<div id="serverList_page" class="page"></div>
<script type="text/template" id="serverList_html">
	<? for ( var i = 0; i < rows.length; i++) {?>
		<tr id=bill_<?=rows[i].billid?>>
			<td><?=rows[i].serverCname?></td>
			<td><?=rows[i].serverIp?></td>
			<td><?=rows[i].serverPort?></td>
			<td>
				<? if (rows[i].serverStatus=="T"){?>				
					启用
				<?}else if (rows[i].serverStatus=="F"){?>
					停用
				<?}?>	
			</td>
			<td><?=rows[i].createTime?></td>
			<td>
				<a class="mybutton"  onclick="editOpen('<?=rows[i].serverId?>');">修改</a> ||
				<a class="mybutton"  onclick="del('<?=rows[i].serverId?>');">删除</a>
			</td>
		</tr>
   <?}?>  		
</script>
<!-- 正文结束 -->

<div class="easyui-dialog" id="addServer_window" title="报价服务器" closed="true" modal="true" style="width:800px;height:400px;top:50px;">
<form id="addServerForm">
<table class="info" cellspacing="1" cellpadding="0">
	<input type="hidden" name="serverId" id="serverId" value="">
	<tr>
		<th>服务器名称：</th>
		<td><input type="text" name="serverCname" id="serverCname"  size="70" maxlength="50" class="easyui-validatebox validatebox-text" 
			validtype="length[1,30]"	required="true"  missingMessage="请输入服务器名称"  
				invalidMessage="最多可输入30中文字符"  title="最多可输入30中文字符" /> </td>
	</tr>
	<tr>
		<th>IP地址：</th>
		<td><input type="text" name="serverIp" id="serverIp" size="20" maxlength="40" class="easyui-validatebox validatebox-text" 
			validtype="ip"	required="true"  missingMessage="请输入IP地址"   title="请输入IP地址" /> </td>
	</tr>
	<tr>
		<th>端口：</th>
		<td><input type="text" name="serverPort" id="serverPort" maxlength="8" size="20"  class="easyui-validatebox validatebox-text" 
			validtype="number"	required="true"  missingMessage="请输入端口号"  invalidMessage="必须为非负数字"  title="端口号" /> </td>
	</tr>
	<tr>
		<th>状态：</th>
		<td>
			<input type="radio" name="serverStatus" value="F" checked="checked"/>停用 &nbsp; &nbsp; &nbsp;
			<input type="radio" name="serverStatus" value="T"/>启用
		 </td>
	</tr>
	<tr>
		<td colspan="2" style="text-align:center;">
			<a class="easyui-linkbutton" id="addButton" iconCls="icon-add" onclick="saveServer();">保存提交</a>
		</td>
	</tr>
</table>
</form>
</div>
</body>
</html>

<script>
//打开查看页面
function view(serverId){
	alert("serverId="+serverId);
	window.location.href= "../viewJsp/server?serverId="+serverId;
}

//查询提交
function serverListSearch(){
	searchSubmit(objName,"serverList");
}

//新增： 打开新增窗口
function addOPen(){
    //clearInputByFormId("addForm");
    $("#serverId").val("");
    clearFormById("addServerForm");
	$("#addServer_window").dialog('open');
}

//提交表单
function saveServer(){
	var serverId = $("#serverId").val();
	if(serverId==""){
		addSubmit(objName,'addServerForm');
	}else{
		editSubmit(objName,serverId,"addServerForm");
	}
}

//新增后回调方法
function addCallBack(flag,msg,objName){
	if(flag=="T"){
		serverListSearch();
	}else{
		alert(msg);
	}
	$("#addServer_window").dialog('close');
	
}

//打开更新页面
function editOpen(objId){
	currentObjId=objId;
	getObj(objName,objId);
}
function getCallBack(flag,obj){
	if("T"==flag){
		loadData(obj,"addServerForm");
		$("#addServer_window").dialog('open');
	}else{
		alert("查询失败");
	}
}

//更新后回调方法
function editCallBack(flag,objName){
	if(flag=="T"){
		serverListSearch();
	}else{
		alert("修改失败！");
	}
	$("#addServer_window").dialog('close');
}

//删除
function del(objId){
	//alert(objId);
	if(confirm("确定要删除吗？")){
		delSubmit(objName,objId);
	}
}
//删除后回调方法
function delCallBack(flag,objName){
	if(flag=="T"){
		serverListSearch();
	}else{
		alert("删除失败！");
	}
}


//初始化加载
$(function(){
	//加载分页列表
	serverListSearch();
});

</script>

